<template>
  <div>
    <img :src="uploadImg" alt="">
    <el-upload
      ref="upload"
      class="upload"
      :http-request="uploadFile"
    >
      <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
      <div slot="tip" class="el-upload__tip">这里是提示文案~</div>
    </el-upload>
  </div>
</template>

<script>
export default {
  name: 'Upload',
  data() {
    return {
      uploadImg: ''
    }
  },
  methods: {
    uploadFile(file) {
      this.uploadFileToAliOss(file).then(resp => {
        console.log(resp)
        this.uploadImg = resp.url
      }).catch(err => {
        console.log(err)
        this.$message('上传文件失败，请重试')
      })
    }
  }

}
</script>

